/**
 * 
 */
package cn.softTank.BpelModelImpl;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.Element;

import cn.softTank.BpelModel.MessageExchange;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class MessageExchangesImpl extends ExtensibleElementImpl implements
		cn.softTank.BpelModel.MessageExchanges {

	private List<MessageExchange> messageExchange;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.MessageExchanges#addMessageExchange(cn.softTank
	 * .BpelModel.MessageExchange)
	 */
	@Override
	public void addMessageExchange(MessageExchange value) {
		if (messageExchange == null)
			messageExchange = new ArrayList<MessageExchange>();
		messageExchange.add(value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.MessageExchanges#getMessageExchange()
	 */
	@Override
	public List<MessageExchange> getMessageExchange() {
		return messageExchange;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.MessageExchanges#removeMessageExchange(int)
	 */
	@Override
	public void removeMessageExchange(int index) {
		if (messageExchange != null && index < messageExchange.size())
			messageExchange.remove(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.MessageExchanges#setMessageExchange(java.util.List)
	 */
	@Override
	public void setMessageExchange(List<MessageExchange> value) {
		messageExchange = value;
	}

	@Override
	public Element toElement() {
		node = super.toElement();
		node.setName("messageExchanges");
		if (messageExchange != null)
			for (int i = 0; i < messageExchange.size(); i++)
				node.add(messageExchange.get(i).toElement());
		return node;
	}

}
